package cloud.estate.car.controller;

import cloud.estate.car.service.CarService;
import cloud.estate.commons.bean.Car;
import cloud.estate.commons.util.JsonResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CarController {
    @Resource
    private CarService carService;
    @PostMapping("/addOneCar")
    public JsonResult addCar(Car car){
        return carService.addCar(car);
    }
    @GetMapping("/findCarById/{id}")
    public JsonResult findCarById(@PathVariable("id") String id){
        return carService.queryCar(id);
    }
    @GetMapping("/findAllCar")
    public JsonResult findAllCar(){
        return carService.queryAllCar();
    }
    @PostMapping("/updateOneCar")
    public JsonResult updateCar( Car car){
        return carService.updateCar(car);
    }
    @PostMapping("/deleteOneCar/{id}")
    public JsonResult deleteCar(@PathVariable("id") String id){
        return carService.deleteCar(id);
    }
}
